pub const USER_STACK_SIZE: usize = 4096 * 2;
pub const KERNEL_STACK_SIZE: usize = 4096 * 2;
pub const KERNEL_HEAP_SIZE: usize = 0x30_0000;
// CLOCK_FREQ 是一个预先获取到的各平台不同的时钟频率，单位为赫兹，也就是一秒钟之内计数器的增量
pub const CLOCK_FREQ: usize = 12500000; // 这里是 qemu 上的数值
pub const BIG_STRIDE: isize = 1 << 20;
pub const INIT_PRORITY: isize = 2;
pub const PAGE_SIZE: usize = 4096; // 每个页面的大小
pub const PAGE_SIZE_BITS: usize = 12; // 页内偏移的位宽 详见(file:///./mm/sv39-va-pa.png)
pub const MEMORY_END: usize = 0x80800000; // 硬编码整块物理内存的终止物理地址为 0x80800000
pub const TRAMPOLINE: usize = usize::MAX - PAGE_SIZE + 1; // 跳板的起始位置 file:///./mm/kernel-as-high.png
pub const TRAP_CONTEXT: usize = TRAMPOLINE - PAGE_SIZE;

/// Return (bottom, top) of a kernel stack in kernel space.
pub fn kernel_stack_position(app_id: usize) -> (usize, usize) {
    let top = TRAMPOLINE - app_id * (KERNEL_STACK_SIZE + PAGE_SIZE);
    let bottom = top - KERNEL_STACK_SIZE;
    (bottom, top)
}